import math
print("""
欢迎使用功能强大，应有尽有的计算器！
版权：ZSN
开发时间：2025.3.26
考试的时候不能用计算器哦～
""")

def Csum(num1, num2):
    return num1 + num2


def Csub(num1, num2):
    return num1 - num2


def Cmulti(num1, num2):
    return num1 * num2


def Cdiv(num1, num2):
    if num2 == 0:
        print("除数不能为0")
        return 0
    return num1 / num2


def Crem(num1, num2):
    if num2 == 0:
        print("取余运算中除数不能为0")
        return 0
    return num1 % num2

def logab(a, b):
    return math.log(a, b)


def sin_cal(num):
    return math.sin(num)


def cos_cal(num):
    return math.cos(num)


def tan_cal(num):
    if math.cos(num) == 0:
        print("正切函数分母不能为0")
        return 0
    return math.tan(num)


def power_cal(num1, num2):
    return num1 ** num2


flag = True
while flag:
    if input("请问需要复数（1）还是整数（2）运算？") == "1":
        num1 = complex(input("请输入一个数："))
        num2 = complex(input("请输入另一个数："))
        choice = input("请输入运算符（+-*/%**）: ")
        if choice == "+":
            print("num1", choice, "num2 = ", Csum(num1, num2))
        elif choice == "-":
            print("num1", choice, "num2 = ", Csub(num1, num2))
        elif choice == "*":
            print("num1", choice, "num2 = ", Cmulti(num1, num2))
        elif choice == "/":
            print("num1", choice, "num2 = ", Cdiv(num1, num2))
        elif choice == "%":
            print("num1", choice, "num2 = ", Crem(num1, num2))
        elif choice == "**":
            print("num1", choice, "num2 = ", power_cal(num1, num2))
        conti = input("是否继续？Y/N：")
        if conti == "Y" or conti == "y":
            flag = True
        else:
            flag = False
    else:
        num1 = int(input("请输入一个数："))
        num2 = int(input("请输入另一个数："))
        choice = input("请输入运算符（+-*/log%sin cos tan**）: ")
        if choice == "+":
            print("num1", choice, "num2 = ", Csum(num1, num2))
        elif choice == "-":
            print("num1", choice, "num2 = ", Csub(num1, num2))
        elif choice == "*":
            print("num1", choice, "num2 = ", Cmulti(num1, num2))
        elif choice == "/":
            print("num1", choice, "num2 = ", Cdiv(num1, num2))
        elif choice == "log":
            print("log以", num1, "为底", num2, "的对数= ", logab(num2, num1))
        elif choice == "%":
            print("num1", choice, "num2 = ", Crem(num1, num2))
        elif choice == "sin":
            print("sin(", num1, ") = ", sin_cal(num1))
        elif choice == "cos":
            print("cos(", num1, ") = ", cos_cal(num1))
        elif choice == "tan":
            print("tan(", num1, ") = ", tan_cal(num1))
        elif choice == "**":
            print("num1", choice, "num2 = ", power_cal(num1, num2))
        conti = input("是否继续？Y/N：")
        if conti == "Y" or conti == "y":
            flag = True
        else:
            flag = False
